import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/home/add_point/index.dart';
import 'package:leader_help/page/home/models/add_point.dart';
import 'package:leader_help/page/home/province_level/widgets/widgets.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/util.dart';

class AddPointCell extends GetView<AddPointController> {
  const AddPointCell({
    Key? key,
    required this.index,
    required this.mod,
  }) : super(key: key);
  final int index;
  final AddPointModel mod;
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 15.r),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Column(
        children: [
          Container(
              alignment: Alignment.centerLeft,
              height: 50.r,
              padding: EdgeInsets.symmetric(horizontal: 15.r),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    '新增任务${index + 1}',
                    style: pfSCStyle(color: ColorsUtil.red, fontSize: 16.sp),
                  ),
                  index == 0
                      ? const SizedBox()
                      : GestureDetector(
                          onTap: () => controller.actionDel(mod),
                          child: Icon(
                            IconUtil.wrong,
                            color: ColorsUtil.content,
                            size: 26.r,
                          ),
                        )
                ],
              )),
          Container(
            color: ColorsUtil.separator,
            height: 0.5,
            width: Get.width,
          ),
          SectionTitle(
            title: '任务内容',
            indent: 15.r,
          ),
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 15.r),
            child: Stack(
              children: [
                UITextField(
                  controller: mod.textCtrl,
                  hintText: '请语音或者手动录入任务内容',
                  align: TextAlignVertical.top,
                  alignment: Alignment.topLeft,
                  height: 200.r,
                  padding: EdgeInsets.all(10.r),
                  border: Border.all(color: ColorsUtil.content, width: 0.5),
                ),
                Positioned(
                  bottom: 50.r,
                  left: (Get.width - 40.r - 60.r) / 2,
                  child: GestureDetector(
                    onTap: () => controller.showPickDialog(index),
                    child: Icon(
                      ProIconUtil.audio,
                      color: ColorsUtil.red,
                      size: 60.r,
                    ),
                  ),
                )
              ],
            ),
          ),
          SizedBox(
            height: 15.r,
          ),
        ],
      ),
    );
  }
}
